/*
**  Copyright (c) 2014 Michael Liu(michael.liu.point@gmail.com).
**
**  Project: Gateway Unified Management Platform
**  File:      cm_test.c
**  Author:  Michael
**  Date:    06/27/2014
**
**  Purpose:
**    wlan cli interface test.
*/

/* Include files. */

#include "cmapi.h"
#include "dpmgr.h"
#include "eamgr.h"
#include "samgr.h"

/* Macro constant definitions. */

/* Type definitions. */

/* Local function declarations. */

/* Macro API definitions. */

/* Global variable declarations. */

twlan_cli_if_linkcfg wlan24g_cli_linkcfg;
twlan_cli_if_linkcfg wlan5g_cli_linkcfg;

int system_get_optmode_test(tcm_session * session)
{
	e_ret ret;
	unsigned char mode;
	ret = dp_cmn_get_dev_optmode(session, &mode);
	printf("dp_cmn_get_dev_optmode() == %d, ret: %d\n", mode, ret);
	return (ret);
}

int system_set_optmode_test(tcm_session * session)
{
	e_ret ret;
	unsigned char mode = eDP_MODE_BRIDGE_AP;
	ret = dp_cmn_set_dev_optmode(session, mode);
	printf("dp_cmn_set_dev_optmode() -> %d, ret: %d\n", mode, ret);
	return (ret);
}

int system_get_country_num_test(tcm_session * session)
{
	e_ret ret;
	unsigned int country_num;

	ret = dp_cmn_get_dev_countryregion(session, &country_num);
	printf("dp_cmn_get_dev_countryregion() -> %d, ret: %d\n", country_num, ret);
	return (ret);
}

int system_set_country_num_test(tcm_session * session)
{
	e_ret ret;
	unsigned int country_num = 156;
	ret = dp_cmn_set_dev_countryregion(session, country_num);
	printf("dp_cmn_set_dev_countryregion() -> %d, ret: %d\n", country_num, ret);
	return (ret);
}

int system_get_macaddr_test(tcm_session * session)
{
	e_ret ret;
	tdevmac devmac;
	ret = dp_cmn_get_dev_mac(session, &devmac);
	printf("dp_cmn_get_dev_mac() lan_mac[%s]\n", devmac.lan_mac);
	printf("dp_cmn_get_dev_mac() 24G_mac[%s]\n", devmac.wlan_24G_mac);
	printf("dp_cmn_get_dev_mac() 5G_mac[%s]\n", devmac.wlan_5G_mac);

	return ret;
}

int br_set_netcfg_dhcp_test(tcm_session * session)
{

	e_ret ret;
	tmask mask;
	tdp_if_netcfg netcfg;

	memset(&mask, 0, sizeof(mask));
	memset(&netcfg, 0, sizeof(netcfg));

	netcfg.conntype = eDP_IF_CONN_TYPE_DHCP;
	mask_set_bit(mask.mask[0], eDP_IF_NETCFG_MASK0_CONNTYPE);

	netcfg.mtu = 1500;
	mask_set_bit(mask.mask[0], eDP_IF_NETCFG_MASK0_MTU);

	netcfg.man_dns = eBOOL_TRUE;
	strcpy(netcfg.dns.dns1, "168.168.0.1");
	strcpy(netcfg.dns.dns1, "8.8.8.8");
	mask_set_bit(mask.mask[0], eDP_IF_NETCFG_MASK0_MANUAL_DNS);

	netcfg.dhcpd_cfg.dhcpd_type = eDP_IF_DHCPD_TYPE_SMART;
	mask_set_bit(mask.mask[0], eDP_IF_NETCFG_MASK0_DHCPD);

	ret = dp_if_setnetcfg(session, "lan", &mask, &netcfg, sizeof(netcfg));
	if (ret != eRET_SUCCESS) {
		printf("dp_if_setnetcfg() failed, mask[0x%08lX][0x%08lX]ret:%d\n", mask.mask[0], mask.mask[1], ret);
		return (ret);
	}

	return (0);

}

int br_set_netcfg_static_test(tcm_session * session)
{

	e_ret ret;
	tmask mask;
	tdp_if_netcfg netcfg;

	memset(&netcfg, 0, sizeof(netcfg));
	memset(&mask, 0, sizeof(mask));

	netcfg.conntype = eDP_IF_CONN_TYPE_STATIC;
	mask_set_bit(mask.mask[0], eDP_IF_NETCFG_MASK0_CONNTYPE);

	netcfg.mtu = 1500;
	mask_set_bit(mask.mask[0], eDP_IF_NETCFG_MASK0_MTU);

	netcfg.man_dns = eBOOL_TRUE;
	strcpy(netcfg.dns.dns1, "168.168.0.1");
	strcpy(netcfg.dns.dns1, "8.8.8.8");
	mask_set_bit(mask.mask[0], eDP_IF_NETCFG_MASK0_MANUAL_DNS);

	strcpy(netcfg.static_conn.ipaddr, "168.168.0.50");
	mask_set_bit(mask.mask[1], eDP_IF_NETCFG_MASK1_STATIC_IPADDR);
	strcpy(netcfg.static_conn.netmask, "255.255.255.0");
	mask_set_bit(mask.mask[1], eDP_IF_NETCFG_MASK1_STATIC_NETMASK);
	strcpy(netcfg.static_conn.defaultgw, "168.168.0.1");
	mask_set_bit(mask.mask[1], eDP_IF_NETCFG_MASK1_STATIC_DEFAULTGW);

	netcfg.dhcpd_cfg.dhcpd_type = eDP_IF_DHCPD_TYPE_DISABLE;
	mask_set_bit(mask.mask[0], eDP_IF_NETCFG_MASK0_DHCPD);

	ret = dp_if_setnetcfg(session, "lan", &mask, &netcfg, sizeof(netcfg));
	if (ret != eRET_SUCCESS) {
		printf("dp_if_setnetcfg() failed, mask[0x%08lX][0x%08lX]ret:%d\n", mask.mask[0], mask.mask[1], ret);
		return (ret);
	}

	return (0);

}

int br_get_netcfg_test(tcm_session * session)
{

	e_ret ret;
	int netcfg_size;
	tdp_if_netcfg *netcfg;

	ret = dp_if_getnetcfg(session, "lan", (void *)&netcfg, &netcfg_size);
	if (ret != eRET_SUCCESS) {
		printf("dp_if_getnetcfg() failed, ret:%d\n", ret);
		return (ret);
	}

	if (netcfg != NULL) {
		printf("if[%s] netcfg\n", "lan");
		printf("\tconnect type: %d\n", netcfg->conntype);
		printf("\tconnect type: %d\n", netcfg->conntype);
		free(netcfg);
	}

	return (0);

}

int br_get_netstatus_test(tcm_session * session)
{

	int i;
	e_ret ret;
	int netstatus_size;
	tdp_if_netstatus *netstatus;

	ret = dp_if_getnetstatus(session, "lan", (void *)&netstatus, &netstatus_size);
	if (ret != eRET_SUCCESS) {
		printf("dp_if_getnetcfg() failed, ret:%d\n", ret);
		return (ret);
	}

	if (netstatus != NULL) {
		printf("if[%s] net status:\n", "lan");
		printf("\tip address: %s\n", netstatus->ipaddr);
		printf("\tnetmask: %s\n", netstatus->netmask);
		printf("\tdefaultgw: %s\n", netstatus->defaultgw);
		printf("\tdns1: %s\n", netstatus->dns.dns1);
		printf("\tdns2: %s\n", netstatus->dns.dns2);
		printf("\tdhcp lease entries[%d]\n", netstatus->dhcp_lease_counter);

		for (i = 0; i < netstatus->dhcp_lease_counter; i++) {
			printf("\t\t[%d]:%s:%s:%luS\n", i,
			       netstatus->dhcp_lease_entry[i].ipaddr,
			       netstatus->dhcp_lease_entry[i].mac, netstatus->dhcp_lease_entry[i].expire);
		}

		free(netstatus);
	}

	return (0);

}

int br_get_linkcfg_test(tcm_session * session)
{

	e_ret ret;
	int linkcfg_size;
	tbridge_if_linkcfg *linkcfg;

	linkcfg = NULL;

	ret = dp_if_br_getlinkcfg(session, "lan", (void *)&linkcfg, &linkcfg_size);
	if (ret != eRET_SUCCESS) {
		printf("dp_if_br_setlinkcfg() failed, ret:%d\n", ret);
	}
	if (linkcfg != NULL) {
		printf("Bridge[%s] uplink interface[%s]\n", "lan", linkcfg->uplink);
		free(linkcfg);
	} else {
		printf("Bridge[%s], get linkcfg return NULL.", "lan");
	}

	return (ret);

}

int wlancli_24g_scan_test(tcm_session * session)
{

	e_ret ret;
	int i;
	twlan_cli_if_link_status *aps;

	/* Just for Test Cancel Async operaion. */
	/* Start. */
	ret = dp_if_wlancli_start_scan_aps(session, "apcli0");
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlancli_start_scan_aps() failed, ret:%d\n", ret);
		return (ret);
	}

	/* Stop. */
	dp_if_wlancli_stop_scan_aps(session, "apcli0");
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlancli_stop_scan_aps() failed, ret:%d\n", ret);
		return (ret);
	}
	/* Just for Test Cancel Async operaion. End */

	/* Start.  */
	ret = dp_if_wlancli_start_scan_aps(session, "apcli0");
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlancli_start_scan_aps() failed, ret:%d\n", ret);
		return (ret);
	}

	do {
		sleep(1);
		ret = dp_if_wlancli_query_scan_aps(session, "apcli0", &aps);
		if (ret == eRET_PENDDING) {
			printf("dp_if_wlancli_query_scan_aps() pending, still scaning.\n");
		} else if (ret == eRET_SUCCESS) {
			printf("dp_if_wlancli_query_scan_aps() finished, get %d aps\n", aps->counter);
			for (i = 0; i < aps->counter; i++) {
				printf("\tap-%02d: ssid[%s], mac[%s], linked[%c],Channel[%d],"
				       "\t\tsignal[%d%%], auth[%d],enc[%d]\n", i,
				       aps->aps[i].ssid, aps->aps[i].bssid, aps->aps[i].linked ? 'Y' : 'N',
				       aps->aps[i].channel, aps->aps[i].signal,
				       aps->aps[i].auth_mode, aps->aps[i].enc_method);
			}
			free(aps);
			break;
		} else {
			printf("dp_if_wlancli_query_scan_aps() failed, ret:%d\n", ret);
			return (ret);
		}
	} while (1);

	return (0);

}

int wlancli_24g_setlinkcfg_test(tcm_session * session)
{

	e_ret ret;
	tmask mask;
	twlan_cli_if_linkcfg linkcfg;

	memset(&linkcfg, 0, sizeof(linkcfg));
	memset(&mask, 0, sizeof(mask));

	str_safe_cpy(linkcfg.ssid, "ASUS_Guest1", WLAN_SSID_SIZE - 1);
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_SSID);

	str_safe_cpy(linkcfg.mac, "74:d0:2b:64:f9:02", RC_MAC_STR_MAX_SIZE - 1);
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_MAC);

	linkcfg.channel = 11;
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_CHANNEL);

	linkcfg.auth_mode = eWLAN_AUTH_MODE_WPA2PSK;
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_AUTH_MODE);

	linkcfg.enc_method = eWLAN_ENC_METHOD_AES;
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_ENC_METHOD);

	str_safe_cpy(linkcfg.sec_key.wpa_psk, "skysoft0", WLAN_ENC_WPA_PSK_MAX_SIZE - 1);
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_SEC_KEY);

	ret = dp_if_wlancli_setlinkcfg(session, "apcli0", &mask, &linkcfg);
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlancli_setlinkcfg() failed, ret:%d\n", ret);
	}

	return (ret);

}

int wlancli_24g_getlinkcfg_test(tcm_session * session)
{

	e_ret ret;
	twlan_cli_if_linkcfg *linkcfg;
	void **tmp;
	int cfg_size;
	unsigned char auth_mode;
	unsigned char enc_method;
	twlan_sec_key *sec_key;

	tmp = (void *)&linkcfg;
	ret = dp_if_wlancli_getlinkcfg(session, "apcli0", tmp, &cfg_size);
	if ((ret != eRET_SUCCESS) || (linkcfg == NULL) || (cfg_size == 0)) {
		printf("dp_if_wlancli_getlinkcfg() failed, ret:%d\n", ret);
		return -1;
	}

	memcpy(&wlan24g_cli_linkcfg, linkcfg, sizeof(wlan24g_cli_linkcfg));
	free(linkcfg);

	/* Dump infomation. */
	auth_mode = wlan24g_cli_linkcfg.auth_mode;
	enc_method = wlan24g_cli_linkcfg.enc_method;
	sec_key = &wlan24g_cli_linkcfg.sec_key;

	printf("if[%s], Auth mode == [%u]; enc method == [%u];\n", "apcli0", auth_mode, enc_method);

	switch (enc_method) {
	case eWLAN_ENC_METHOD_NONE:
		break;

	case eWLAN_ENC_METHOD_WEP:
		printf("key default id [%u]:\n"
		       "1: value: [%s]\n"
		       "2: value: [%s]\n"
		       "3: value: [%s]\n"
		       "4: value: [%s]\n",
		       sec_key->wep_key.default_id,
		       sec_key->wep_key.key[0].value,
		       sec_key->wep_key.key[1].value, sec_key->wep_key.key[2].value, sec_key->wep_key.key[3].value);
		break;

	case eWLAN_ENC_METHOD_TKIP:
	case eWLAN_ENC_METHOD_AES:
	case eWLAN_ENC_METHOD_TKIP_AES:
		printf("key[%s];\n", sec_key->wpa_psk);
		break;
	}

	return (ret);

}

int wlancli_24g_getlinkstatus_test(tcm_session * session)
{

	e_ret ret;
	int i;
	int counter;
	twlan_cli_if_link_status *aps;

	counter = 6;
	do {
		sleep(1);
		ret = dp_if_wlancli_getlinkstatus(session, "apcli0", &aps);
		printf("dp_if_wlancli_getlinkstatus() ret: %d, aps: %p\n", ret, aps);
		if (ret == eRET_SUCCESS) {
			printf("dp_if_wlancli_getlinkstatus() finished, get %d aps\n", aps->counter);
			printf("\tap-%02d: ssid[%s], bssid[%s], linked[%c],Channel[%d]\n"
			       "\tsignal[%d%%], auth[%d],enc[%d], tx:%ld.%ldMbit/s, rx:%ld.%ldMbit/s\n", i,
			       aps->aps[0].ssid, aps->aps[0].bssid, aps->aps[0].linked ? 'Y' : 'N',
			       aps->aps[0].channel, aps->aps[0].signal, aps->aps[0].auth_mode,
			       aps->aps[0].enc_method,
			       (aps->aps[0].tx_rate / (1000 * 1000)),
			       ((aps->aps[0].tx_rate % (1000 * 1000)) / (100 * 1000)),
			       (aps->aps[0].rx_rate / (1000 * 1000)),
			       ((aps->aps[0].rx_rate % (1000 * 1000)) / (100 * 1000)));
			free(aps);
			if (aps->aps[0].linked) {
				return (0);
			}
		} else {
			printf("dp_if_wlancli_getlinkstatus() failed, ret:%d\n", ret);
		}
	} while (counter-- > 0);

	return (1);

}

int wlanap_24g_setlinkcfg_test(tcm_session * session, twlan_cli_if_linkcfg * cli_cfg)
{

	e_ret ret;
	tmask mask;
	twlan_ap_if_linkcfg linkcfg;

	memset(&linkcfg, 0, sizeof(linkcfg));
	memset(&mask, 0, sizeof(mask));

	snprintf(linkcfg.ssid, WLAN_SSID_SIZE - 1, "%s-RPT", cli_cfg->ssid);
	linkcfg.ssid[WLAN_SSID_SIZE - 1] = 0;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_SSID);

	linkcfg.mode = eWLAN24G_MODE_AUTO;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_MODE);
#if 0
	linkcfg.auth_mode = cli_cfg->auth_mode;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_AUTH_MODE);

	linkcfg.enc_method = cli_cfg->enc_method;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_ENC_METHOD);

	memcpy(&linkcfg.sec_key, &cli_cfg->sec_key, sizeof(linkcfg.sec_key));
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_SEC_KEY);
#else
	linkcfg.auth_mode = eWLAN_AUTH_MODE_SHARED;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_AUTH_MODE);

	linkcfg.enc_method = eWLAN_ENC_METHOD_WEP;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_ENC_METHOD);

	strcpy(linkcfg.sec_key.wep_key.key[0].value, "12345");
	linkcfg.sec_key.wep_key.default_id = 1;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_SEC_KEY);
#endif
	linkcfg.acl.acl_type = 2;
	linkcfg.acl.counter = 2;
	strcpy(linkcfg.acl.acl[0].mac, "11:11:33:33:44:55");
	strcpy(linkcfg.acl.acl[1].mac, "11:11:33:33:44:56");
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_ACL);

	linkcfg.rtsthreshold = 2340;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_RTSTHRESHOLD);

	linkcfg.fragthreshold = 2341;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_FRAGTHRESHOLD);

	linkcfg.dtimperiod = 10;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_DTIMPERIOD);

	linkcfg.txburst = 0;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_TXBURST);

	linkcfg.pktaggregate = 0;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_PKTAGGREGATE);

	linkcfg.greenap = 1;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_GREENAP);

	ret = dp_if_wlanap_setlinkcfg(session, "ra0", &mask, &linkcfg);
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlanap_setlinkcfg() failed, ret:%d\n", ret);
	}

	return (ret);

}

int wlancli_5g_scan_test(tcm_session * session)
{

	e_ret ret;
	int i;
	twlan_cli_if_link_status *aps;

	/* Just for Test Cancel Async operaion. */
	/* Start. */
	ret = dp_if_wlancli_start_scan_aps(session, "apclii0");
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlancli_start_scan_aps() failed, ret:%d\n", ret);
		return (ret);
	}

	/* Stop. */
	dp_if_wlancli_stop_scan_aps(session, "apclii0");
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlancli_stop_scan_aps() failed, ret:%d\n", ret);
		return (ret);
	}
	/* Just for Test Cancel Async operaion. End */

	/* Start again. */
	ret = dp_if_wlancli_start_scan_aps(session, "apclii0");
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlancli_start_scan_aps() failed, ret:%d\n", ret);
		return (ret);
	}

	do {
		sleep(1);
		ret = dp_if_wlancli_query_scan_aps(session, "apclii0", &aps);
		if (ret == eRET_PENDDING) {
			printf("dp_if_wlancli_query_scan_aps() pending, still scaning.\n");
		} else if (ret == eRET_SUCCESS) {
			printf("dp_if_wlancli_query_scan_aps() finished, get %d aps\n", aps->counter);
			for (i = 0; i < aps->counter; i++) {
				printf("\tap-%02d: ssid[%s], mac[%s], linked[%c],Channel[%d],"
				       "\t\tsignal[%d%%], auth[%d],enc[%d]\n", i,
				       aps->aps[i].ssid, aps->aps[i].bssid, aps->aps[i].linked ? 'Y' : 'N',
				       aps->aps[i].channel, aps->aps[i].signal,
				       aps->aps[i].auth_mode, aps->aps[i].enc_method);
			}
			free(aps);
			break;
		} else {
			printf("dp_if_wlancli_query_scan_aps() failed, ret:%d\n", ret);
			return (ret);
		}
	} while (1);

	return (0);

}

int wlancli_5g_setlinkcfg_test(tcm_session * session)
{

	e_ret ret;
	tmask mask;
	twlan_cli_if_linkcfg linkcfg;

	memset(&linkcfg, 0, sizeof(linkcfg));
	memset(&mask, 0, sizeof(mask));

	str_safe_cpy(linkcfg.ssid, "ASUS_RPN53_5G", WLAN_SSID_SIZE - 1);
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_SSID);

	str_safe_cpy(linkcfg.mac, "40:16:7e:b7:76:76", RC_MAC_STR_MAX_SIZE - 1);
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_MAC);

	linkcfg.channel = 149;
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_CHANNEL);

	linkcfg.auth_mode = eWLAN_AUTH_MODE_OPEN;
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_AUTH_MODE);

	linkcfg.enc_method = eWLAN_ENC_METHOD_NONE;
	mask_set_bit(mask.mask[0], eWLAN_CLI_IF_LINKCFG_MASK0_ENC_METHOD);

	ret = dp_if_wlancli_setlinkcfg(session, "apclii0", &mask, &linkcfg);
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlancli_setlinkcfg() failed, ret:%d\n", ret);
	}

	return (ret);

}

int wlancli_5g_getlinkcfg_test(tcm_session * session)
{

	e_ret ret;
	twlan_cli_if_linkcfg *linkcfg;
	void **tmp;
	int cfg_size;
	unsigned char auth_mode;
	unsigned char enc_method;
	twlan_sec_key *sec_key;

	tmp = (void *)&linkcfg;
	ret = dp_if_wlancli_getlinkcfg(session, "apclii0", tmp, &cfg_size);
	if ((ret != eRET_SUCCESS) || (linkcfg == NULL) || (cfg_size == 0)) {
		printf("dp_if_wlancli_getlinkcfg() failed, ret:%d\n", ret);
		return -1;
	}

	memcpy(&wlan5g_cli_linkcfg, linkcfg, sizeof(wlan5g_cli_linkcfg));
	free(linkcfg);

	/* Dump infomation. */
	auth_mode = wlan5g_cli_linkcfg.auth_mode;
	enc_method = wlan5g_cli_linkcfg.enc_method;
	sec_key = &wlan5g_cli_linkcfg.sec_key;

	printf("if[%s], Auth mode == [%u]; enc method == [%u];\n", "apclii0", auth_mode, enc_method);

	switch (enc_method) {
	case eWLAN_ENC_METHOD_NONE:
		break;

	case eWLAN_ENC_METHOD_WEP:
		printf("key default id [%u]:\n"
		       "1: value: [%s]\n"
		       "2: value: [%s]\n"
		       "3: value: [%s]\n"
		       "4: value: [%s]\n",
		       sec_key->wep_key.default_id,
		       sec_key->wep_key.key[0].value,
		       sec_key->wep_key.key[1].value, sec_key->wep_key.key[2].value, sec_key->wep_key.key[3].value);
		break;

	case eWLAN_ENC_METHOD_TKIP:
	case eWLAN_ENC_METHOD_AES:
	case eWLAN_ENC_METHOD_TKIP_AES:
		printf("key[%s];\n", sec_key->wpa_psk);
		break;
	}

	return (ret);

}

int wlancli_5g_getlinkstatus_test(tcm_session * session)
{

	e_ret ret;
	int i;
	int counter;
	twlan_cli_if_link_status *aps;

	counter = 6;
	do {
		sleep(1);
		ret = dp_if_wlancli_getlinkstatus(session, "apclii0", &aps);
		printf("dp_if_wlancli_getlinkstatus() ret: %d, aps: %p\n", ret, aps);
		if (ret == eRET_SUCCESS) {
			printf("dp_if_wlancli_getlinkstatus() finished, get %d aps\n", aps->counter);
			printf("\tap-%02d: ssid[%s], bssid[%s], linked[%c],Channel[%d]\n"
			       "\tsignal[%d%%], auth[%d],enc[%d], tx:%ld.%ldMbit/s, rx:%ld.%ldMbit/s\n", i,
			       aps->aps[0].ssid, aps->aps[0].bssid, aps->aps[0].linked ? 'Y' : 'N',
			       aps->aps[0].channel, aps->aps[0].signal, aps->aps[0].auth_mode,
			       aps->aps[0].enc_method,
			       (aps->aps[0].tx_rate / (1000 * 1000)),
			       ((aps->aps[0].tx_rate % (1000 * 1000)) / (100 * 1000)),
			       (aps->aps[0].rx_rate / (1000 * 1000)),
			       ((aps->aps[0].rx_rate % (1000 * 1000)) / (100 * 1000)));

			free(aps);
			if (aps->aps[0].linked) {
				return (0);
			}
		} else {
			printf("dp_if_wlancli_getlinkstatus() failed, ret:%d\n", ret);
		}
	} while (counter-- > 0);

	return (1);

}

int wlanap_5g_setlinkcfg_test(tcm_session * session, twlan_cli_if_linkcfg * cli_cfg)
{

	e_ret ret;
	tmask mask;
	twlan_ap_if_linkcfg linkcfg;

	memset(&linkcfg, 0, sizeof(linkcfg));
	memset(&mask, 0, sizeof(mask));

	snprintf(linkcfg.ssid, WLAN_SSID_SIZE - 1, "%s-RPT5G", cli_cfg->ssid);
	linkcfg.ssid[WLAN_SSID_SIZE - 1] = 0;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_SSID);

	linkcfg.mode = eWLAN5G_MODE_AUTO;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_MODE);
#if 0
	linkcfg.auth_mode = cli_cfg->auth_mode;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_AUTH_MODE);

	linkcfg.enc_method = cli_cfg->enc_method;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_ENC_METHOD);

	memcpy(&linkcfg.sec_key, &cli_cfg->sec_key, sizeof(linkcfg.sec_key));
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_SEC_KEY);
#else
	linkcfg.auth_mode = eWLAN_AUTH_MODE_SHARED;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_AUTH_MODE);

	linkcfg.enc_method = eWLAN_ENC_METHOD_WEP;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_ENC_METHOD);

	strcpy(linkcfg.sec_key.wep_key.key[0].value, "12345");
	linkcfg.sec_key.wep_key.default_id = 1;
	mask_set_bit(mask.mask[0], eWLAN_AP_IF_LINKCFG_MASK0_SEC_KEY);
#endif
	ret = dp_if_wlanap_setlinkcfg(session, "rai0", &mask, &linkcfg);
	if (ret != eRET_SUCCESS) {
		printf("wlanap_5g_setlinkcfg_test() failed, ret:%d\n", ret);
	}

	return (ret);

}

int wlanap_24g_station_info_test(tcm_session * session)
{
	e_ret ret;
	int i;
	twlan_ap_if_link_status *clients;

	ret = dp_if_wlanap_getlinkstatus(session, "ra0", &clients);
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlanap_getlinkstatus() failed, ret:%d\n", ret);
		return (ret);
	}

	if (clients == NULL) {
		printf("dp_if_wlanap_getlinkstatus() failed, clients NULL\n");
		return (eRET_FAILURE);
	}

	printf("dp_if_wlanap_getlinkstatus() got [%d] clients\n", clients->counter);

	for (i = 0; i < clients->counter; i++) {
		printf("-------- -------- -------- -------- -------- --------\n");
		printf("MAC:%s\n", clients->clients[i].cli_mac.mac);
		printf("PowerSave:%c\n", clients->clients[i].power_save ? 'Y' : 'N');
		printf("BW:%d\n", clients->clients[i].bw);
		printf("rssi0:%d\n", clients->clients[i].rssi0);
		printf("rssi1:%d\n", clients->clients[i].rssi1);
		printf("rssi2:%d\n", clients->clients[i].rssi2);
		printf("tx_rate:%ld.%ldMbit/s\n", (clients->clients[i].tx_rate / (1000 * 1000)),
		       ((clients->clients[i].tx_rate % (1000 * 1000)) / (100 * 1000)));
		printf("rx_rate:%ld.%ldMbit/s\n", (clients->clients[i].rx_rate / (1000 * 1000)),
		       ((clients->clients[i].rx_rate % (1000 * 1000)) / (100 * 1000)));
	}

	return (ret);

}

int wlanap_5g_station_info_test(tcm_session * session)
{
	e_ret ret;
	int i;
	twlan_ap_if_link_status *clients;

	ret = dp_if_wlanap_getlinkstatus(session, "rai0", &clients);
	if (ret != eRET_SUCCESS) {
		printf("dp_if_wlanap_getlinkstatus() failed, ret:%d\n", ret);
		return (ret);
	}

	if (clients == NULL) {
		printf("dp_if_wlanap_getlinkstatus() failed, clients NULL\n");
		return (eRET_FAILURE);
	}

	printf("dp_if_wlanap_getlinkstatus() got [%d] clients\n", clients->counter);

	for (i = 0; i < clients->counter; i++) {
		printf("-------- -------- -------- -------- -------- --------\n");
		printf("MAC:%s\n", clients->clients[i].cli_mac.mac);
		printf("PowerSave:%c\n", clients->clients[i].power_save ? 'Y' : 'N');
		printf("BW:%d\n", clients->clients[i].bw);
		printf("rssi0:%d\n", clients->clients[i].rssi0);
		printf("rssi1:%d\n", clients->clients[i].rssi1);
		printf("rssi2:%d\n", clients->clients[i].rssi2);
		printf("tx_rate:%ld.%ldMbit/s\n", (clients->clients[i].tx_rate / (1000 * 1000)),
		       ((clients->clients[i].tx_rate % (1000 * 1000)) / (100 * 1000)));
		printf("rx_rate:%ld.%ldMbit/s\n", (clients->clients[i].rx_rate / (1000 * 1000)),
		       ((clients->clients[i].rx_rate % (1000 * 1000)) / (100 * 1000)));
	}

	return (ret);

}

int ether_getlinkstatus_test(tcm_session * session)
{

	e_ret ret;
	teth_if_link_status *status;

	ret = dp_if_ether_getlinkstatus(session, "eth2.2", &status);
	printf("dp_if_ether_getlinkstatus() ret: %d, status: %p\n", ret, status);
	if ((ret == eRET_SUCCESS) && (status != NULL)) {
		printf("linked:%d, speed:%d, dumplex:%d\n", status->linked, status->speed, status->dumplex);
		free(status);
	} else {
		printf("dp_if_ether_getlinkstatus() failed, ret:%d\n", ret);
	}

	return (1);

}

int sa_sysmgr_test(tcm_session * session)
{

	e_ret ret;
	unsigned char password_ok;
	unsigned char qis_done;
	char *pswd;

	/* Blank password to check if password been set. */
	pswd = "";
	ret = sa_sm_verify_password(session, pswd, &password_ok);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_verify_password() failed, ret:%d\n", ret);
	}

	if (password_ok == eBOOL_TRUE) {
		printf("password[%s] is ok.\n", pswd);
	} else {
		printf("password[%s] is failed.\n", pswd);
	}

	/* Set password */
	pswd = "admin";
	ret = sa_sm_set_password(session, pswd);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_set_password() failed, ret:%d\n", ret);
	} else {
		printf("sa_sm_set_password() ok, ret:%d\n", ret);
	}

	/* check incorrect password. */
	pswd = "";
	ret = sa_sm_verify_password(session, pswd, &password_ok);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_verify_password() failed, ret:%d\n", ret);
	}

	if (password_ok == eBOOL_TRUE) {
		printf("password[%s] is ok.\n", pswd);
	} else {
		printf("password[%s] is failed.\n", pswd);
	}

	/* check correct password. */
	pswd = "admin";
	ret = sa_sm_verify_password(session, pswd, &password_ok);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_verify_password() failed, ret:%d\n", ret);
	}

	if (password_ok == eBOOL_TRUE) {
		printf("password[%s] is ok.\n", pswd);
	} else {
		printf("password[%s] is failed.\n", pswd);
	}

	/* Get password */
	char pswd1[32];
	ret = sa_sm_get_password(session, pswd1);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_get_password() failed, ret:%d\n", ret);
	} else {
		printf("sa_sm_get_password() ok, ret:%d\n", ret);
	}
	printf("pswd is %s\n", pswd1);

	/* Check QIS status. */
	ret = sa_sm_get_qis(session, &qis_done);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_verify_password() failed, ret:%d\n", ret);
	}

	if (qis_done == eBOOL_TRUE) {
		printf("QIS completed.\n");
	} else {
		printf("Need to do QIS.\n");
	}

	/* Set QIS done. */
	ret = sa_sm_set_qis(session, eBOOL_TRUE);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_set_qis() failed, ret:%d\n", ret);
	} else {
		printf("sa_sm_set_qis() ok, ret:%d\n", ret);
	}

	/* Check QIS status. */
	ret = sa_sm_get_qis(session, &qis_done);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_verify_password() failed, ret:%d\n", ret);
	}

	if (qis_done == eBOOL_TRUE) {
		printf("QIS completed.\n");
	} else {
		printf("Need to do QIS.\n");
	}

	/* Check set datetime. */
/*	struct date_time dt;
	dt.year = 2014;
	dt.month = 7;
	dt.day = 18;
	dt.hour = 17;
	dt.minute = 16;
	dt.second = 30;
	ret = sa_sm_set_datetime(session, dt);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_set_datetime() failed, ret:%d\n", ret);
	}*/

	/* Check get datetime. */
/*	struct date_time datetime;
	ret = sa_sm_get_datetime(session, &datetime);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_get_datetime() failed, ret:%d\n", ret);
	} else {
		printf("=======sys time========\n");
		printf("year %d\n", datetime.year);
		printf("moutn %u\n", datetime.month);
		printf("day %d\n", datetime.day);
		printf("hour %u\n", datetime.hour);
		printf("minute %u\n", datetime.minute);
		printf("second %u\n", datetime.second);
	}*/

	/* Check get uptime. */
/*	struct date_time uptime;
	ret = sa_sm_get_uptime(session, &uptime);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_get_uptime() failed, ret:%d\n", ret);
	} else {
		printf("=======up time========\n");
		printf("uptime year %d\n", uptime.year);
		printf("uptime moutn %u\n", uptime.month);
		printf("uptime day %d\n", uptime.day);
		printf("uptime hour %u\n", uptime.hour);
		printf("uptime minute %u\n", uptime.minute);
		printf("uptime second %u\n", uptime.second);
	}*/

	/* check language */
/*	unsigned char lang;
	lang = 2;
	ret = sa_sm_set_language(session, lang);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_set_language() failed, ret:%d\n", ret);
	}

	unsigned char language;
	ret = sa_sm_get_language(session, &language);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_get_language() failed, ret:%d\n", ret);
	} else {
		printf("language is %u \n", language);
	}*/

	/* check ntp server */
/*	char net_server1[] = "www.abc.com";
	ret = sa_sm_set_ntp(session, net_server1);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_set_ntp() failed, ret:%d\n", ret);
	}

	char net_server[32];
	ret = sa_sm_get_ntp(session, net_server);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_set_ntp() failed, ret:%d\n", ret);
	} else {
		printf("net server is %s\n", net_server);
	}*/

	/* check timezone */
/*	unsigned int timezone;
	timezone = 1;
	ret = sa_sm_set_timezone(session, timezone);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_set_timezone() failed, ret:%d\n", ret);
	}

	unsigned int timezone1;
	ret = sa_sm_get_timezone(session, &timezone1);
	if (ret != eRET_SUCCESS) {
		printf("sa_sm_get_timezone() failed, ret:%d\n", ret);
	} else {
		printf("timezone1 is %u \n", timezone1);
	}*/

	/* check dump_cfg */
/*	char dump_cfg[CFG_MGR_CFG_FILE_NAME_SIZE];
	ret = sa_cm_dump_cfg(session, dump_cfg);
	if (ret != eRET_SUCCESS) {
		printf("sa_cm_dump_cfg() failed, ret:%d\n", ret);
	} else {
		printf("dump_cfg is %s \n", dump_cfg);
	}*/

	/* check load_cfg */
/*	char load_cfg[CFG_MGR_CFG_FILE_NAME_SIZE];
	strcpy(load_cfg, "/tmp/config_file");
	ret = sa_cm_load_cfg(session, load_cfg);
	if (ret != eRET_SUCCESS) {
		printf("sa_cm_load_cfg() failed, ret:%d\n", ret);
	} else {
		printf("load_cfg is %s \n", load_cfg);
	}*/

	/*check reset_cfg */

/*	ret = sa_cm_reset_cfg(session);
	if (ret != eRET_SUCCESS) {
		printf("sa_cm_reset_cfg() failed, ret:%d\n", ret);
	}*/

	/* check reboot system */
	/*ret = sa_sm_reboot(session);
	   if (ret != eRET_SUCCESS) {
	   printf("sa_sm_reboot() failed, ret:%d\n", ret);
	   } */

/*	{
		unsigned char powersave;
		ret = sa_sm_get_power_save(session, &powersave);
		if (ret != eRET_SUCCESS) {
			printf("sa_sm_get_power_save() failed, ret:%d\n", ret);
		} else {
			printf("sa_sm_get_power_save() power save[%d], ret:%d\n", powersave, ret);
		}

		powersave = eBOOL_TRUE;
		ret = sa_sm_set_power_save(session, powersave);
		if (ret != eRET_SUCCESS) {
			printf("sa_sm_set_power_save() failed, ret:%d\n", ret);
		} else {
			printf("sa_sm_set_power_save() power save[%d], ret:%d\n", powersave, ret);
		}

		sleep(2);

		ret = sa_sm_get_power_save(session, &powersave);
		if (ret != eRET_SUCCESS) {
			printf("sa_sm_get_power_save() failed, ret:%d\n", ret);
		} else {
			printf("sa_sm_get_power_save() power save[%d], ret:%d\n", powersave, ret);
		}

		powersave = eBOOL_FALSE;
		ret = sa_sm_set_power_save(session, powersave);
		if (ret != eRET_SUCCESS) {
			printf("sa_sm_set_power_save() failed, ret:%d\n", ret);
		} else {
			printf("sa_sm_set_power_save() power save[%d], ret:%d\n", powersave, ret);
		}

	}
*/
	return (ret);

}

int fm_sysmgr_test(tcm_session * session)
{
	e_ret ret;

	/* check get version */
	char version[32];
	ret = sa_fm_get_version(session, version);
	if (ret != eRET_SUCCESS) {
		printf("sa_fm_get_version() failed, ret:%d\n", ret);
	} else {
		printf("sa_fm_get_version() fota[%s], ret:%d\n", version, ret);
	}

	ret = sa_fm_start_fota_check(session);
	printf("sa_fm_start_fota_check() ret[%d]\n", ret);

	/* check fota info */
	int time = 0;
	do {
		ret = sa_fm_query_fota_check(session, version);
		time++;
		sleep(1);
		printf("sa_fm_query_fota_check(),time[%d],ret[%d]\n", time, ret);
	} while (ret == eRET_PENDDING && time < 30);

	if (ret != eRET_SUCCESS) {
		ret = sa_fm_cancel_fota_check(session);
		printf("sa_fm_cancel_fota_check(), ret[%d]\n", ret);
	}
	printf("sa_fm_query_fota_check() fota_version [%s]\n", version);

	ret = sa_fm_start_fota_upgrade(session);
	printf("sa_fm_start_fota_upgrade() ret[%d]\n", ret);

	time = 0;
	do {
		ret = sa_fm_query_fota_upgrade(session);
		time++;
		sleep(1);
		printf("sa_fm_query_fota_upgrade(),time[%d],ret[%d]\n", time, ret);
	} while (ret == eRET_PENDDING && time < 60);

	if (ret != eRET_SUCCESS) {
		ret = sa_fm_cancel_fota_upgrade(session);
		printf("sa_fm_cancel_fota_upgrade(), ret[%d]\n", ret);
	}

	/* local upgrade */
/*	char fw_name[] = "/tmp/AP4100W";
	ret = sa_fm_local_upgrade(session, fw_name);
	if (ret != eRET_SUCCESS) {
		printf("sa_fm_local_upgrade() failed, ret:%d\n", ret);
	} else {
		printf("sa_fm_local_upgrade() failed ret:%d\n", ret);
	}*/
	return ret;
}

int main(int argc, char **argv)
{

	e_ret ret;
	int rc;
	int opt;
	tcm_session session;

	ret = cmapi_create_session(&session, "test_app");
	if (ret != eRET_SUCCESS) {
		printf("cmapi_create_session() failed, ret:%d", ret);
		return (ret);
	}

	if (argc < 2) {
		opt = 0;
	} else if (strcasecmp(argv[1], "2g") == 0) {
		opt = 0;
	} else if (strcasecmp(argv[1], "5g") == 0) {
		opt = 1;
	} else if (strcasecmp(argv[1], "sm") == 0) {
		opt = 2;
	} else if (strcasecmp(argv[1], "stainfo") == 0) {
		opt = 3;
	} else if (strcasecmp(argv[1], "br_netstatus") == 0) {
		opt = 4;
	} else if (strcasecmp(argv[1], "br_dhcp") == 0) {
		opt = 5;
	} else if (strcasecmp(argv[1], "br_static") == 0) {
		opt = 6;
	} else if (strcasecmp(argv[1], "br_getnetcfg") == 0) {
		opt = 7;
	} else if (strcasecmp(argv[1], "getmode") == 0) {
		opt = 8;
	} else if (strcasecmp(argv[1], "setmode") == 0) {
		opt = 9;
	} else if (strcasecmp(argv[1], "eth") == 0) {
		opt = 10;
	} else if (strcasecmp(argv[1], "setcountry") == 0) {
		opt = 11;
	} else if (strcasecmp(argv[1], "getcountry") == 0) {
		opt = 12;
	} else if (strcasecmp(argv[1], "fm") == 0) {
		opt = 13;
	} else if (strcasecmp(argv[1], "getmac") == 0) {
		opt = 14;
	} else {
		printf("Unsupport operation[%s]", argv[1]);
		opt = -1;
	}

	switch (opt) {
	case 0:
		rc = wlancli_24g_scan_test(&session);
		printf("wlancli_24g_scan_test() rc: %d\n", rc);
		rc = wlancli_24g_setlinkcfg_test(&session);
		printf("wlancli_24g_setlinkcfg_test() rc: %d\n", rc);
		rc = br_get_linkcfg_test(&session);
		printf("br_get_linkcfg_test() rc: %d\n", rc);
		if (wlancli_24g_getlinkstatus_test(&session) != 0) {
			printf("24g wlan cli connect failed.\n");
		} else {
			printf("24g wlan cli connect success.\n");
		}

		rc = wlancli_24g_getlinkcfg_test(&session);
		printf("wlancli_24g_getlinkcfg_test() rc: %d\n", rc);

		rc = wlanap_24g_setlinkcfg_test(&session, &wlan24g_cli_linkcfg);
		printf("wlanap_24g_setlinkcfg_test() rc: %d\n", rc);
		rc = wlanap_5g_setlinkcfg_test(&session, &wlan24g_cli_linkcfg);
		printf("wlanap_5g_setlinkcfg_test() rc: %d\n", rc);
		break;

	case 1:
		wlancli_5g_scan_test(&session);
		wlancli_5g_setlinkcfg_test(&session);
		rc = br_get_linkcfg_test(&session);
		printf("br_get_linkcfg_test() rc: %d\n", rc);
		if (wlancli_5g_getlinkstatus_test(&session) != 0) {
			printf("5g wlan cli connect failed.\n");
		} else {
			printf("5g wlan cli connect success.\n");
		}

		rc = wlancli_5g_getlinkcfg_test(&session);
		printf("wlancli_5g_getlinkcfg_test() rc: %d\n", rc);

		rc = wlanap_24g_setlinkcfg_test(&session, &wlan5g_cli_linkcfg);
		printf("wlanap_24g_setlinkcfg_test() rc: %d\n", rc);
		rc = wlanap_5g_setlinkcfg_test(&session, &wlan5g_cli_linkcfg);
		printf("wlanap_5g_setlinkcfg_test() rc: %d\n", rc);
		break;

	case 2:
		sa_sysmgr_test(&session);
		break;

	case 3:
		rc = wlanap_24g_station_info_test(&session);
		printf("wlanap_24g_station_info_test() rc: %d\n", rc);
		rc = wlanap_5g_station_info_test(&session);
		printf("wlanap_5g_station_info_test() rc: %d\n", rc);
		break;

	case 4:
		rc = br_get_netstatus_test(&session);
		printf("br_get_netstatus_test() rc: %d\n", rc);
		break;

	case 5:
		rc = br_set_netcfg_dhcp_test(&session);
		printf("br_set_netcfg_dhcp_test() rc: %d\n", rc);
		break;

	case 6:
		rc = br_set_netcfg_static_test(&session);
		printf("br_set_netcfg_static_test() rc: %d\n", rc);
		break;

	case 7:
		rc = br_get_netcfg_test(&session);
		printf("br_get_netcfg_test() rc: %d\n", rc);
		break;

	case 8:
		rc = system_get_optmode_test(&session);
		printf("system_get_optmode_test() rc: %d\n", rc);
		break;

	case 9:
		rc = system_set_optmode_test(&session);
		printf("system_set_optmode_test() rc: %d\n", rc);
		break;

	case 10:
		rc = ether_getlinkstatus_test(&session);
		printf("ether_getlinkstatus_test() rc: %d\n", rc);
		break;

	case 11:
		rc = system_set_country_num_test(&session);
		printf("system_set_country_num_test() rc: %d\n", rc);
		break;

	case 12:
		rc = system_get_country_num_test(&session);
		printf("system_get_country_num_test() rc: %d\n", rc);
		break;

	case 13:
		rc = fm_sysmgr_test(&session);
		printf("fm_sysmgr_test() rc: %d\n", rc);
		break;

	case 14:
		rc = system_get_macaddr_test(&session);
		printf("system_get_macaddr_test() rc: %d\n", rc);
		break;

	default:
		break;
	}

	ret = cmapi_destroy_session(&session);
	if (ret != eRET_SUCCESS) {
		printf("cmapi_create_session() failed, ret:%d", ret);
		return (ret);
	}
	return (0);

}
